/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.webhomesites.padrao.utils;

import br.com.webhomesites.locacao.model.ItemLocacaoModel;
import com.lowagie.text.pdf.CMYKColor;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class PintarTabela extends DefaultTableCellRenderer {

    public Component getTableCellRendererComponent(JTable table,
            Object value, boolean isSelected, boolean hasFocus, int row,
            int column) {

        Component c = super.getTableCellRendererComponent(table,
                value, isSelected, hasFocus, row, column);
        String status;
        String pagamento;
        if (true) {
            //for (int i = 0; i < table.getRowCount(); i++) {            
            status = (String) table.getValueAt(row, 7);
            pagamento = (String) table.getValueAt(row, 8);//Exemplo se fosse em uma determinada linha.
            
            Color colorVerde = new CMYKColor(101,0,101,0);
            Color colorAzul = new CMYKColor(101,50,0,0);
            Color colorAmarelo = new CMYKColor(0,0,153,0);
            Color colorCinza = new CMYKColor(50,50,0,0);            
            
            if (status.equals("A") && pagamento.equals("N")) {
                c.setBackground(colorAmarelo);
            } else if (status.equals("D") && pagamento.equals("S")) {
                c.setBackground(colorVerde);
            } else if (status.equals("D") && pagamento.equals("N")) {
                c.setBackground(colorAzul);
            } else if (status.equals("A") && pagamento.equals("S")) {
                c.setBackground(colorCinza);
            }
            return c;
        }
        return c;
    }
    
}
